package com.flying.invest.invest.model;

import java.util.Date;

import com.flying.common.util.Codes;
import com.flying.framework.annotation.ConstantEnum;
import com.flying.framework.annotation.Param;
import com.flying.framework.annotation.ServiceField;
import com.flying.framework.annotation.ServiceFieldParam;
import com.flying.framework.data.Data;
import com.flying.framework.data.DataSerializable;
import com.flying.framework.metadata.Meta;
import com.flying.invest.invest.TransactionType;
import com.flying.invest.strategy.model.Strategy;
import com.flying.invest.strategy.model.StrategyType;

@SuppressWarnings("serial")
@Meta(id="i_investment_suggestion",title="投资建议", table="i_investment_suggestion", primaryKeys={"suggestion_id"})
public class InvestmentSuggestion extends Data implements DataSerializable {
	public final static String ENTITY_NAME = "i_investment_suggestion";
	
	public final static String SUGGESTION_ID = "suggestion_id";
	public final static String USER_ID = "user_id";
	public final static String INVEST_ID = "invest_id";
	public final static String STRATEGY_ID = "strategy_id";
	public final static String BATCH_NUM = "batch_num";
	public final static String NAME = "name";
	public final static String REMARKS = "remarks";
	public final static String TRANSACTION_TYPE = "transaction_type";
	public final static String AMOUNT = "amount";
	public final static String QUANTITY = "quantity";
	public final static String FROM_DATE = "from_date";
	public final static String TO_DATE = "to_date";
	public final static String STATUS = "status";
	public final static String TRANSACTION_DATE = "transaction_date";
	public final static String TRANSACTION_ID = "transaction_id";
	public final static String CANCEL_TYPE = "cancel_type";
	public final static String CANCEL_MSG = "cancel_msg";
	public final static String CANCEL_DATE = "cancel_date";
	public final static String EXTRA = "extra";
	public final static String CREATOR = "creator";
	public final static String CREATE_TIME = "create_time";
	public final static String UPDATOR = "updator";
	public final static String UPDATE_TIME = "update_time";
	
	public enum Status implements ConstantEnum<Integer> {
		PREPARING(0, "待执行"), ORDERED(1, "已下单"), INVESTED(2, "交易成功"), FAILED(3, "交易失败"), CANCELED(4, "取消执行");

		public final int value;
		public final String remarks;

		Status(int value, String remarks) {
			this.value = value;
			this.remarks = remarks;
		}
		
		@Override
		public Integer value() {
			return this.value;
		}

		@Override
		public String text() {
			return remarks;
		}
	}
	
	
	@Param(value=SUGGESTION_ID,   required=true,   maxlength=0,	desc="建议ID" , generator=Codes.AUTO_INCREMENT)
	private Long suggestionId;
	
	@Param(value=USER_ID,   required=true,   maxlength=0,	desc="所属用户" )
	private Long userId;
	
	@Param(value=INVEST_ID,   required=true,   maxlength=0,	desc="投资ID" )
	private Long investId;
	
	@Param(value=STRATEGY_ID,   required=true,   maxlength=0,	desc="策略ID" )
	private Long strategyId;
	
	@Param(value=BATCH_NUM,   required=true,   maxlength=0,	desc="批号" )
	private Integer batchNum;
	
	@Param(value=NAME,   required=false,   maxlength=50,	desc="投资项目" )
	private String name;
	
	@Param(value=REMARKS,   required=false,   maxlength=400,	desc="说明" )
	private String remarks;
	
	@Param(value=TRANSACTION_TYPE,   required=true,   maxlength=0, enumClass=TransactionType.class,	desc="交易类型（1：买入；-1：卖出）" )
	private Integer transactionType;
	
	@Param(value=AMOUNT,   required=true,   maxlength=0,	desc="金额" )
	private Double amount;
	
	@Param(value=QUANTITY,   required=false,   maxlength=0,	desc="交易数量" )
	private Double quantity;
	
	@Param(value=FROM_DATE,   required=false,   maxlength=0,	desc="开始日期" )
	private Date fromDate;
	
	@Param(value=TO_DATE,   required=false,   maxlength=0,	desc="截至日期" )
	private Date toDate;
	
	@Param(value=STATUS,   required=false,   maxlength=0, enumClass=Status.class,	desc="状态" )
	private Integer status;
	
	@Param(value=TRANSACTION_DATE,   required=false,   maxlength=0,	desc="交易日期" )
	private Date transactionDate;
	
	@Param(value=TRANSACTION_ID,   required=false,   maxlength=0,	desc="交易ID" )
	private Long transactionId;
	
	@Param(value=CANCEL_TYPE,   required=false,   maxlength=0, desc="取消类型" )
	private Integer cancelType;
	
	@Param(value=CANCEL_MSG,   required=false,   maxlength=40,	desc="取消说明" )
	private String cancelMsg;
	
	@Param(value=CANCEL_DATE,   required=false,   maxlength=0,	desc="取消时间" )
	private Date cancelDate;
	
	@Param(value=EXTRA,   required=false,   maxlength=40,	desc="附加信息" )
	private String extra;
	
	@Param(value=CREATOR,   required=false,   maxlength=40,	desc="创建人" )
	private String creator;
	
	@Param(value=CREATE_TIME,   required=false,   maxlength=0,	desc="创建时间" )
	private Date createTime;
	
	@Param(value=UPDATOR,   required=false,   maxlength=40,	desc="修改人" )
	private String updator;
	
	@Param(value=UPDATE_TIME,   required=false,   maxlength=0,	desc="修改时间" )
	private Date updateTime;

	@ServiceField(serviceId="StrategyTypeService:findByStrategyId", params={@ServiceFieldParam(param=Strategy.STRATEGY_ID, value="$"+STRATEGY_ID)})
	@Param(value="strategyType",   required=false,	desc="策略类型", ignored=true)
	private StrategyType strategyType;
	
	
	public Long getSuggestionId() {
		return this.suggestionId;
	}
	
	public void setSuggestionId(Long suggestionId) {
		this.suggestionId = suggestionId;
	}
	
	public Long getUserId() {
		return this.userId;
	}
	
	public void setUserId(Long userId) {
		this.userId = userId;
	}
	
	public Long getInvestId() {
		return investId;
	}

	public void setInvestId(Long investId) {
		this.investId = investId;
	}

	public Long getStrategyId() {
		return this.strategyId;
	}
	
	public void setStrategyId(Long strategyId) {
		this.strategyId = strategyId;
	}
	
	public Integer getBatchNum() {
		return this.batchNum;
	}
	
	public void setBatchNum(Integer batchNum) {
		this.batchNum = batchNum;
	}
	
	public String getName() {
		return this.name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	public String getRemarks() {
		return this.remarks;
	}
	
	public void setRemarks(String remarks) {
		this.remarks = remarks;
	}
	
	public Integer getTransactionType() {
		return this.transactionType;
	}
	
	public void setTransactionType(Integer transactionType) {
		this.transactionType = transactionType;
	}
	
	public Double getAmount() {
		return this.amount;
	}
	
	public void setAmount(Double amount) {
		this.amount = amount;
	}
	
	public Double getQuantity() {
		return quantity;
	}

	public void setQuantity(Double quantity) {
		this.quantity = quantity;
	}

	public Date getFromDate() {
		return this.fromDate;
	}
	
	public void setFromDate(Date fromDate) {
		this.fromDate = fromDate;
	}
	
	public Date getToDate() {
		return this.toDate;
	}
	
	public void setToDate(Date toDate) {
		this.toDate = toDate;
	}
	
	public Integer getStatus() {
		return this.status;
	}
	
	public void setStatus(Integer status) {
		this.status = status;
	}
	
	public Date getTransactionDate() {
		return this.transactionDate;
	}
	
	public void setTransactionDate(Date transactionDate) {
		this.transactionDate = transactionDate;
	}
	
	public Long getTransactionId() {
		return this.transactionId;
	}
	
	public void setTransactionId(Long transactionId) {
		this.transactionId = transactionId;
	}

	public Integer getCancelType() {
		return cancelType;
	}

	public void setCancelType(Integer cancelType) {
		this.cancelType = cancelType;
	}

	public String getCancelMsg() {
		return cancelMsg;
	}

	public void setCancelMsg(String cancelMsg) {
		this.cancelMsg = cancelMsg;
	}

	public Date getCancelDate() {
		return cancelDate;
	}

	public void setCancelDate(Date cancelDate) {
		this.cancelDate = cancelDate;
	}

	public String getExtra() {
		return extra;
	}

	public void setExtra(String extra) {
		this.extra = extra;
	}

	public String getCreator() {
		return creator;
	}

	public void setCreator(String creator) {
		this.creator = creator;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public String getUpdator() {
		return updator;
	}

	public void setUpdator(String updator) {
		this.updator = updator;
	}

	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	public StrategyType getStrategyType() {
		return strategyType;
	}
	
	public String getStrategyTypeName() {
		StrategyType t = this.getStrategyType();
		return t == null? null: t.getName();
	}
}